/*
 * msgHeaderDefs.h
 *
 * Created: 6/18/2013 2:16:48 AM
 *  Author: Tim
 */ 


#ifndef MSGHEADERDEFS_H_
#define MSGHEADERDEFS_H_

#include <inttypes.h>

//same for all messages
#define packetHeader		0x55

//message header index

/************GEN***************/

#define general_mh_msk		0xF0

#define xtrg_mh				0xFE

#define resetDaq_mh			0xFD

#define programStart_mh		0xFC

#define programStop_mh		0xFB

#define daqReady_mh			0xFA

#define daqStandAloneEn_mh	0xF9

#define daqEndOfProgram_mh	0xF8	

/************ADC***************/

#define adc_mh_msk			0x00

#define adcInitAsync_mh		0x01

#define adcResult0_mh		0x02

#define adcResult1_mh		0x03

#define adcResult2_mh		0x04

#define adcResult3_mh		0x05

#define adcFlashInit_mh		0x06

#define adcResult_mh		0x07

/************DAC***************/

#define dac_mh_msk			0x10

#define dacInitWaveform_mh	0x11

#define dacEnable_mh		0x12

#define dacDisable_mh		0x13

#define dacUpdate_mh		0x14

/************DIO***************/

#define dio_mh_msk			0x20

#define dioInitPolling_mh	0x21

#define dioCurrentState_mh	0x22

#define dioDirSet_mh		0x23

#define dioDirClr_mh		0x24

#define dioOutSet_mh		0x25

#define dioOutClr_mh		0x26

/************ENC***************/

#define enc_mh_msk			0x30

#define encInitAsync_mh		0x31

#define encCurCount_mh		0x32

/***********FLASH**************/

#define flash_mh_msk		0x40

#define flashAdcInfo_mh		0x41

#define flashAdcData0_mh	0x42

#define flashAdcData1_mh	0x43

#define flashAdcData2_mh	0x44

#define flashAdcData3_mh	0x45


static inline uint16_t packetSizeLookup(uint8_t msgeHeader)
{
	switch(msgeHeader)
	{
		//general messages
		case xtrg_mh:
			return	6;
		break;
		case resetDaq_mh:
			return	4;
		break;
		case programStart_mh:
			return	4;
		break;
		case programStop_mh:
			return	4;
		break;
		case daqReady_mh:
			return	4;
		break;
		case daqStandAloneEn_mh:
			return	4;
		break;	
		case daqEndOfProgram_mh:
			return	4;
		break;
		//adc messages
		case adcInitAsync_mh:
			return	7;
		break;
		case adcResult0_mh:
			return	6;
		break;
		case adcResult1_mh:
			return	6;
		break;
		case adcResult2_mh:
			return	6;
		break;
		case adcResult3_mh:
			return	6;
		break;
		case adcFlashInit_mh:
			return  9;
		break;
		case adcResult_mh:
			return  12;
		break;
		//dac messages
		case dacInitWaveform_mh:
			return	9;	
		break;
		case dacEnable_mh:
			return	5;
		break;
		case dacDisable_mh:
			return	5;
		break;
		case dacUpdate_mh:
			return	6;
		break;
		//dio messages
		case dioInitPolling_mh:
			return	6;
		break;
		case dioCurrentState_mh:
			return	6;
		break;
		case dioDirSet_mh:
			return	6;
		break;
		case dioDirClr_mh:
			return	6;
		break;
		case dioOutSet_mh:
			return	6;	
		break;
		case dioOutClr_mh:
			return	6;		
		break;
		//encoder messages
		case encInitAsync_mh:
			return	8;
		break;
		case encCurCount_mh:
			return	6;
		break;
		//flash messages	
		case flashAdcInfo_mh:
			return	7;	
		break;
		case flashAdcData0_mh:
			return	260;
		break;
		case flashAdcData1_mh:
			return	260;
		break;
		case flashAdcData2_mh:
			return	260;
		break;
		case flashAdcData3_mh:
			return	260;
		break;
	}
	//for whatever reason I cannot get the default keyword to be recognized so here is a catch all
	return 0;	//bad message header
			
}

#endif /* MSGHEADERDEFS_H_ */